package cn.com.dcsgo.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * SpringDoc配置类
 *
 * @author Dcsgo
 * @since 2025/9/28 18:47
 */
@Configuration
public class SpringDocConfiguration {
    @Resource
    private SpringDocProperties springDocProperties;

    @Bean
    public OpenAPI springProjectOpenOpi() {
        return new OpenAPI()
                .info(new Info()
                        .title(springDocProperties.getTitle())
                        .description(springDocProperties.getDescription())
                        .version(springDocProperties.getVersion())
                        .contact(new Contact()
                                .name(springDocProperties.getContactName())
                                .email(springDocProperties.getContactEmail())
                        )
                        .license(new
                                License().name(springDocProperties.getLicenseName())
                                .url(springDocProperties.getLicenseUrl())
                        )
                ).externalDocs(new ExternalDocumentation()
                        .description(springDocProperties.getExternalDocsDes())
                        .url(springDocProperties.getExternalDocsUrl())
                );
    }
}
